﻿#ifndef _DBOPERATOR_H_INCLUDE_
#define _DBOPERATOR_H_INCLUDE_

#include <QMutex>

#include "common.h"
#include "database/ndbpool/sqlitedataprovider.h"
#include "baserole.h"

class DBOperator : public SqliteDataProvider
{
    Q_OBJECT

public:
    DBOperator(QObject *parent = nullptr);
    ~DBOperator();

    /// 得到用户数据
    bool getUserData(QString username,QString userpwd,tagDBUserData *pUserData,
                                QString connectionName,
                                bool longConnect);
    /// 根据用户ID得到用户数据
    bool getUserDataById(int userId,QString password,tagDBUserData *pUserData,
                         QString connectionName,
                         bool longConnect);
    /// 更新用户信息
    bool updateUserData(tagDBUserData *pUserData,
                        QString connectionName="qt_sql_default_connection",
                        bool longConnect=true);
    /// 更新用户地图信息
    bool updateUserMapData(BaseRole *pBaseRole,
                           QString connectionName="qt_sql_default_connection",
                           bool longConnect=true);

    /// 更新用户游戏数据信息
    bool updateUserGameData(BaseRole *pBaseRole,
                            QString connectionName="qt_sql_default_connection",
                            bool longConnect=true);

private:
    QMutex m_mutexhtmldataprovider;
};

#endif // DBOPERATOR_H
